# student_list = [
#     {'no': 1, 'name': '小明', 'age': 13, 'sex': 'male'},
#     {'no': 2, 'name': '小红', 'age': 12, 'sex': 'female'},
#     {'no': 2, 'name': '小红', 'age': 12, 'sex': 'female'},
# ]
# def print_welcom_info():
#     print("""
#         1-查询学员姓名
#         2-添加学员姓名
#         3-修改学员姓名
#         4-删除学员姓名
#         0-退出程序
#         """)
# def get_user_input():
#     select_num=int(input('请输入你要选择的序号:'))
#     if select_num in ['1','2','3','4','0']:
#         return int(select_num)
#     else:
#         print('输入错误')
#         return None
# def get_stu_list():
#     print('{:<8}{:<8}{:<8}{:<8}{:<8}'.format('索引', '学号', '姓名', '年龄', '性别'))
#     for index, stu in enumerate(student_list):
#         no = stu['no']
#         name = stu['name']
#         age = stu['age']
#         sex = stu['sex']
#         print('{:<10}{:<10}{:<10}{:<10}{:<10}'.format(index, no, name, age, sex))
#         # print('索引{}，学号{}，名字{}，年龄{},性别{}'.format(index,no,name,age,sex))
#     print('打印成功')
#
# while True:
#     print_welcom_info()
#     select_num = get_user_input()
#     if not select_num:
#         continue
#     else:
#         if select_num == 1:
#             get_stu_list()
#         else:
#             break

student_list = [
    {'no': 1, 'name': '小明', 'age': 13, 'sex': 'male'},
    {'no': 2, 'name': '小红', 'age': 12, 'sex': 'female'},
    {'no': 2, 'name': '小红', 'age': 12, 'sex': 'female'},
]

while True:
    print("""
        1-查询学员姓名
        2-修改学员姓名
        3-添加学员姓名
        4-删除学员姓名
        0-退出程序
    """)
    num=int(input('请输入你要选择的序号:'))
    while num < 0 or num > 4:
        num=int(input('输入错误,请重新输入:'))
    if num==1:
        print('{:<8}{:<8}{:<8}{:<8}{:<8}'.format('索引', '学号', '姓名', '年龄', '性别'))
        for index, stu in enumerate(student_list):
            no = stu['no']
            name=stu['name']
            age=stu['age']
            sex = stu['sex']
            print('{:<10}{:<10}{:<10}{:<10}{:<10}'.format(index, no, name, age, sex))
    if num==2:
        print('{:<8}{:<8}{:<8}{:<8}{:<8}'.format('索引', '学号', '姓名', '年龄', '性别'))
        for index, stu in enumerate(student_list):
            no = stu['no']
            name = stu['name']
            age = stu['age']
            sex = stu['sex']
            print('{:<10}{:<10}{:<10}{:<10}{:<10}'.format(index, no, name, age, sex))
        student=input('你想修改那个学生,输入他的索引')

        if student.isdigit()and int(student)in range(0,len(student_list)):

            new_name=input('要修改的名字:')
            new_age=int(input('修改后的年龄:'))
            new_sex=input('修改后的性别:')
            student_list[int(student)]['name']=new_name
            student_list[int(student)]['age']=new_age
            student_list[int(student)]['sex']=new_sex
            print('修改成功')
    if num==3:
        no = input('请输入你要添加的学号:')
        name = input('请输入你要添加的名字:')
        age = int(input('请输入你要添加的年龄:'))
        sex = input('请输入你要添加的性别:')

        new_stu = {}
        new_stu['no']=no
        new_stu['name']=name
        new_stu['age']=age
        new_stu['sex']=sex
        student_list.append(new_stu)
        print('添加成功')
    if num==4:
        print('{:<8}{:<8}{:<8}{:<8}{:<8}'.format('索引', '学号', '姓名', '年龄', '性别'))
        for index, stu in enumerate(student_list):
            no = stu['no']
            name = stu['name']
            age = stu['age']
            sex = stu['sex']
            print('{:<10}{:<10}{:<10}{:<10}{:<10}'.format(index, no, name, age, sex))
        number=int(input('请输入你想删除的学生，根据索引删除'))
        if number in range(0,len(student_list)):
            student_list.pop(int(number))
            print('删除成功！')
        else:
            print('用户不存在，没办法删除！')
    # if number.isdigit() and int(number) in range(0,len(student_list)):













